package com.noocodecommit.wicket.jquery.plugin.ui.autocomplete;

import java.util.ArrayList;
import java.util.List;

import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.repeater.data.ListDataProvider;

import com.noocodecommit.wicket.jquery.TemplatePage;
import com.noocodecommit.wicket.stuff.jquery.JQCore;
import com.noocodecommit.wicket.stuff.jquery.plugin.chili.JQChili;
import com.noocodecommit.wicket.stuff.jquery.plugin.ui.autocomplete.JQAutocomplete;
import com.noocodecommit.wicket.stuff.jquery.plugin.ui.tabs.JQTabs;

public class AutocompletePage extends TemplatePage
{
	private final JQTabs tabContainer;
	
	public AutocompletePage()
	{
		super();
		this.setupChili();
		
		tabContainer = new JQTabs("tab-container");
		tabContainer.setOutputMarkupId(true);
		add(tabContainer);
		
		List<String> cities = new ArrayList<String>();
		cities.add("Rouen");
		cities.add("Bordeaux");
		cities.add("Paris");
		cities.add("La Neuville Chant d'Oisel");
		cities.add("Pont Saint Pierre");
		cities.add("Rennes");
		cities.add("Marseille");
		cities.add("Lyon");
		cities.add("Toulouse");
		cities.add("Nice");
		cities.add("Nantes");
		cities.add("Strasbourg");
		cities.add("Montpellier");
		cities.add("Lille");
		cities.add("Reims");
		cities.add("Le Havre");
		cities.add("Saint-Etienne");
		cities.add("Toulon");
		cities.add("Grenoble");
		cities.add("Angers");
		
		/**
		 * Autocomplete
		 */
		ListDataProvider dataProvider = new ListDataProvider(cities);
		TextField city = new TextField("city");
		city.setOutputMarkupId(true);
		tabContainer.add(city);
		JQAutocomplete autocomplete = new JQAutocomplete("autocomplete", city, dataProvider);
		autocomplete.setOutputMarkupId(true);
		tabContainer.add(autocomplete);
		
		JQChili chili1 = new JQChili("chili1");
		add(chili1);
		this.bindChiliCode(chili1, this.getClass(), "html");

		JQChili chili2 = new JQChili("chili2");
		add(chili2);
		this.bindChiliCode(chili2, this.getClass(), "java");
		
		JQCore.get().bindOnDocumentReadyFunction();
	}
}